﻿using ChatBackend.Entity;
using SqlSugar;

namespace ChatBackend.DBContext.TestRepository
{
    public class TestRepository : BaseRepository<TestEntity>, ITestRepository
    {
        private readonly ISqlSugarClient _db;

        public TestRepository(ISqlSugarClient db) : base(db)
        {
            _db = db;
        }

        public async Task<int> AddTestAsync(TestEntity para)
        {
            var result = await _db.Insertable(para).ExecuteCommandAsync();
            return result;
        }

        public async Task<List<TestEntity>> QueryTestListAsync()
        {
            var result = await _db.Queryable<TestEntity>().ToListAsync();
            return result;
        }

        public async Task<int> DeleteTestAsync(string Id)
        {
            var result = await _db.Deleteable<TestEntity>().Where(x => x.Id == Id).ExecuteCommandAsync();
            return result;
        }

        public async Task<int> ModifyTestAsync(TestEntity para)
        {
            var result = await _db.Updateable(para).ExecuteCommandAsync();
            return result;
        }
    }
}